part of 'home_page.dart';

Future<List<String>> _androidFilePicker(webview_flutter_android.FileSelectorParams params) async {
  PermissionStatus status = await Permission.camera.request();

  if (status == PermissionStatus.permanentlyDenied) {
    AppStr.permissionObtain.toast();

  } else if (status == PermissionStatus.granted) {

    final XFile? photo = await ImagePicker().pickImage(
        source: ImageSource.camera,
        maxWidth: 2048,
        maxHeight: 2048
    );

    if (photo == null) {
      debugPrint('photo 为null');
      return [];
    }

    debugPrint('photo path: ${photo.path}');

    String? compressPath = await ImageUtils.compressImage(photo.path, 1.5 * 1024 * 1024, 90);
    debugPrint('compressPath path: ${photo.path}');

    if (compressPath == null) {
      debugPrint('compressPath 为null');
      return [];
    }

    return [File(compressPath).uri.toString()];

  } else {
    debugPrint('触发filepicker 权限不允许');
  }

  return [];
}

